package com.ruoyi.front_desk.FrontdeskRepresentativePerformance.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.front_desk.FrontdeskRepresentativePerformance.domain.FrontdeskRepresentativePerformance;
import com.ruoyi.front_desk.FrontdeskRepresentativePerformance.mapper.FrontdeskRepresentativePerformanceMapper;
import com.ruoyi.front_desk.FrontdeskRepresentativePerformance.service.FrontdeskRepresentativeService;
import com.ruoyi.management_controller.RepresentativePerformance.domain.RepresentativePerformance;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 刘奥旸
 * @version 1.0
 */
@Service
public class FrontdeskRepresentativeImpl implements FrontdeskRepresentativeService {
@Resource
public FrontdeskRepresentativePerformanceMapper frontdeskRepresentativePerformanceMapper;
    @Override
    public List<RepresentativePerformance> selectById(String date,Integer id) {
        if (id == 0){
            List<RepresentativePerformance> all = frontdeskRepresentativePerformanceMapper.selectRepresentativePerformanceAll();
            return all;
        }else {
            String firstYear=DateUtils.getFirstYear(date);
            String lastYear=DateUtils.getLastYear(date);
            return frontdeskRepresentativePerformanceMapper.selectRepresentativePerformanceById(id,firstYear,lastYear);
        }

    }

    @Override
    public List<RepresentativePerformance> selectByDate(String date,int id) {
        String firstYear=DateUtils.getFirstYear(date);
        String lastYear=DateUtils.getLastYear(date);
        return frontdeskRepresentativePerformanceMapper.findByDate(id,firstYear,lastYear);
    }
}
